<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.yunhe.bean.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" +request.getServerPort() + path + "/";
%>
<!-- 如果直接登陆该页面，则页面转向到控制器 -->
<c:if test="${map.productList==null }">
<c:redirect url="../showProduct_Servlet"></c:redirect>
</c:if>
<jsp:include page="head.jsp"></jsp:include>
	<div class="main">
		<h2>商品管理</h2>
		<div class="manage">
			<table class="list">
				<tr>
					<th>编号</th>
					<th>商品名称</th>
					<th>操作</th>
				</tr>
				<!-- 循环遍历商品，五个位一页 -->
<c:if test="${map!=null}">
   <c:if test="${map.productList!=null }">
     <c:forEach items="${map.productList}" var="obj">   
				<tr>				    
					<td class="first w4 c"><c:out value="${obj.commodityID}"></c:out></td>
					<td class="thumb"><img src="<%=basePath %>${obj.pictureSource}" /><a href="../product-view.html" target="_self"><c:out value="${obj.commodityName}"></c:out></a></td>
					<td class="w1 c">
					<a href="<%=basePath %>showProduct_Servlet?cid=${obj.commodityID}&manage=change">修改</a> 
					<a class="manageDel" href="<%=basePath %>ChangeAddDeleteProduct_Servlet?id=${obj.commodityID}&manage=delete">删除</a></td>
				</tr>
  </c:forEach>
   </c:if>
</c:if>
			</table>
		</div>
	</div>
	<div class="clear"></div>
    <div class="pager">
    <!-- 分页显示 -->
				<ul class="clearfix">
					<li><a href="<%=basePath %>showProduct_Servlet?currentPage=1">首页</a></li>
					<li>
<c:if test="${requestScope.map.page.currentPage!=1}">
<a href="<%=basePath %>showProduct_Servlet?currentPage=${requestScope.map.page.currentPage-1 }">上一页</a>
</c:if>
                    </li>
                    <li>
<c:if test="${requestScope.map.page.currentPage!=requestScope.map.totalPage}">
<a href="<%=basePath %>showProduct_Servlet?currentPage=${requestScope.map.page.currentPage+1 }">下一页</a>
</c:if>
                    </li>
					<li><a href="<%=basePath %>showProduct_Servlet?currentPage=${requestScope.map.totalPage}">尾页</a></li>
				</ul>
  </div>
</div>

<div id="footer">
	Copyright &copy; 2017云和学院 All Rights Reserved. 京ICP证1000001号</div>
	
	

	
	
<script type="text/javascript">
$(".manageDel").click(function(){
var $tr = $(this).parent().parent();
if(confirm("确定要删除吗？")) {
if($tr) $tr.remove();
location.herf="";
}else{
return false;}
})
</script>
	
</body>
</html>

